package cn.Liujialin.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 接口统一返回对象
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

   private Boolean success = true;
   private String message = "操作成功！";

   //后面用
   private Object resultObj;


   public static AjaxResult me(){
       return new AjaxResult();
   }

   //失败构造
    public static AjaxResult fail(String message){
       return me().setSuccess(false).setMessage(message);
    }

    /**
     * 链式编程思维
     * @param success
     * @return
     */
    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setMessage(String message) {
        this.message = message;
        return this;
    }
    public AjaxResult setResultObj(Object  resultObj) {
        this.resultObj = resultObj;
        return this;
    }


}
